#include <iostream>
#include "Evaluation.h"
#include "PMX.h"
using namespace std;

void PMX::Run( std::vector<Solution> &output, const Solution &solution_1, const Solution &solution_2 )
{
	int keep_job_num = Evaluation::GetJobNum() / 2 ,keep_job_start = Evaluation::GetJobNum() / 4 
		,keep_job_end = keep_job_start + keep_job_num - 1 ,x = keep_job_end + 1;
	vector<int> solution(Evaluation::GetJobNum() , 0);
	for( int i = 0; i < Evaluation::GetJobNum(); ++i ){
		solution[i] = solution_2.getElementAt(i);
	}
	for( int i = keep_job_start ; i <= keep_job_end ; ++i ){
		for( int j = 0 ; j < Evaluation::GetJobNum() ; ++j ){
			if( solution[j] == solution_1[i] ){
				swap(  solution[i], solution[j] );
			}
		}
	}
	output.push_back( Solution(solution) );

	for( int i = 0; i < Evaluation::GetJobNum(); ++i ){
		solution[i] = solution_1.getElementAt(i);
	}
	for( int i = keep_job_start ; i <= keep_job_end ; ++i ){
		for( int j = 0 ; j < Evaluation::GetJobNum() ; ++j ){
			if( solution[j] == solution_2[i] ){
				swap(  solution[i], solution[j] );
			}
		}
	}
	output.push_back( Solution(solution) );
}
